package com.brsya.movie.application;

import android.app.Application;

import com.brsya.base.base.Contents;
import com.brsya.base.bean.PlayAddressBean;
import com.brsya.base.util.ACache;
import com.brsya.base.util.LoggerUtil;
import com.brsya.movie.BuildConfig;
import com.brsya.movie.constant.Constant;
import com.umeng.commonsdk.UMConfigure;

/**
 * Created by Brsya
 * CreateDate: 2022/6/30  11:35
 * Description:
 * 应用Application
 */
public class MyApplication extends Application {
    public static ACache aCache;
    public static PlayAddressBean playAddressBean;

    private static MyApplication application;

    public static boolean isOpenAd() {
        return true;
    }

    @Override
    public void onCreate() {
        super.onCreate();
        application = this;
        aCache = ACache.get(this);

        init();

        LoggerUtil.e("start_type：" + BuildConfig.DEBUG);

    }

    /**
     * 初始化穿山甲聚合广告SDK
     */
    private void initAdSDk() {
        if (!isAgree()) {
            return;
        }

    }

    /**
     * 是否同意用户协议
     * @return 是否同意用户协议
     */
    public static boolean isAgree(){
        if (aCache == null) {
            return false;
        }

        return "true".equals(aCache.getAsString(Constant.CACHE_KEY_IS_AGREE));
    }

    /**
     * 同意用户协议
     */
    public static void setAgree(){
        if (aCache == null) {
            return;
        }
        aCache.put(Constant.CACHE_KEY_IS_AGREE, "true");
    }

    /**
     * 初始化必要SDK
     */
    public static void init(){
        if (application == null) {
            return;
        }
        application.initAdSDk();
    }


}
